import { createSlice, PayloadAction } from '@reduxjs/toolkit'
const userInfoState = { token: '', nickname: '' } as userType
const userSlice = createSlice({
    name: 'user',
    initialState: userInfoState,
    reducers: {
        setInfoUser: (state: userType, action: PayloadAction<userType>) => {
            console.log(action.payload.nickname);

            return action.payload
        },
        removeInfoUser: () => userInfoState,
        getInfoUser: (state: userType) => state
    }
})

export const { setInfoUser, removeInfoUser, getInfoUser } = userSlice.actions

export const userReducer = userSlice.reducer

export type userType = {
    token: string,
    nickname: string,
}
